package ink.tiptop.common.domain;

import ink.tiptop.common.domain.rsp.FailedResponse;
import ink.tiptop.common.domain.rsp.Response;
import ink.tiptop.enums.EResp;
import ink.tiptop.service.ResponseService;

/**
 * @author ink.tiptop.zjf
 * @Title: Ticket
 * @Package ink.tiptop.dto.resp
 * @Description: 当前项目的响应service
 * @date 2020-07-20 10:22
 */
public class WebworkResponse implements ResponseService {

    private String respCode;
    private String respMsg;

    public WebworkResponse(String respCode, String respMsg ) {
        this.respCode = respCode;
        this.respMsg = respMsg;
    }
    public WebworkResponse(EResp resp) {
        this.respCode = resp.respCode;
        this.respMsg = resp.respMsg;
    }

    public static final Response SUCCEED = new FailedResponse(new WebworkResponse(EResp.SUCCESS));

    public static final Response ERROR = new FailedResponse(new WebworkResponse(EResp.ERROR));

    public static Response failed(EResp resp) {
        return new FailedResponse(new WebworkResponse(resp.respCode,resp.respMsg));
    }
    public static Response failed(EResp.EModuleLocal resp) {
        return new FailedResponse(new WebworkResponse(resp.respCode,resp.respMsg));
    }
    public static Response failed(EResp.EUserAuth resp) {
        return new FailedResponse(new WebworkResponse(resp.respCode,resp.respMsg));
    }
    public static Response failed(EResp.EVersion resp) {
        return new FailedResponse(new WebworkResponse(resp.respCode,resp.respMsg));
    }
    public static Response failed(EResp.EServerInfo resp) {
        return new FailedResponse(new WebworkResponse(resp.respCode,resp.respMsg));
    }

    public static Response failed(EResp.EViewLocal resp) {
        return new FailedResponse(new WebworkResponse(resp.respCode, resp.respMsg));
    }

    public static Response failed(EResp.EViewRemote resp) {
        return new FailedResponse(new WebworkResponse(resp.respCode, resp.respMsg));
    }

    public static Response failed(EResp.EKey resp) {
        return new FailedResponse(new WebworkResponse(resp.respCode, resp.respMsg));
    }

    public static Response failed(EResp.EPublish resp) {
        return new FailedResponse(new WebworkResponse(resp.respCode, resp.respMsg));
    }

    @Override
    public String respCode() {
        return respCode;
    }

    @Override
    public String respMsg() {
        return respMsg;
    }

}
